package com.example.fw;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class HelperWithDriverBase extends HelperBase {
	
	protected WebDriver driver;

	public HelperWithDriverBase(ApplicationManager manager) {
		super(manager);
		driver = manager.getWebDriverHelper().getDriver();
		
	}

	protected void type(String locator, String lastname) {
		driver.findElement(By.name(locator)).clear();
		driver.findElement(By.name(locator)).sendKeys(lastname);
	}

	protected boolean isElementPresent(By by) {
		try {
			driver.findElement(by);
			return true;
		} catch (NoSuchElementException e) {
			return false;
		}
	}

	protected WebElement findElement(By name) {
		return driver.findElement(name);
	}

	protected List<WebElement> findElements(By name) {
		return driver.findElements(name);
	}
	
	protected void openUrl(String string) {
		driver.get(string);
	}

	protected void click(By name) {
		findElement(name).click();
	}
}
